#ifndef __DP_CONNECTION__
#define __DP_CONNECTION__ 

#include <iostream>
#include <packet_quer.h>

struct connection
{
    unsigned int addr1;
    unsigned int addr2;
    unsigned short port1;
    unsigned short port2;
    connection(unsigned int a1, unsigned int a2, 
            unsigned short p1, unsigned short p2)
        : addr1(a1), addr2(a2), port1(p1), port2(p2)
    {
    }

    connection(const connection& to_be_copied)      
    {
        addr1 = to_be_copied.addr1;
        addr2 = to_be_copied.addr2;
        port1 = to_be_copied.port1;
        port2 = to_be_copied.port2;

#ifdef DEBUG_EXTNSV
        std::cout << "connection object copy constructed \n";
#endif
    }

    void setval(unsigned int a1, unsigned int a2,
            unsigned short p1, unsigned short p2)
    {
        addr1 = a1;
        addr2 = a2;
        port1 = p1;
        port2 = p2;
    }

    ~connection()
    {
#ifdef DEBUG_EXTNSV
        std::cout << "connection destroyed \n";
#endif 

    }

    bool operator < (const connection & temp) const
    {
        return true;
    }

};


typedef enum  { TRYING_TO_CONNECT, CONNECTED, TRYING_TO_DISCONNECT, 
    DISCONNECTED , CONNECTION_NOT_ADDED} connection_state;

class Connections
{
    public:

    connection_state getConnectionInfo(connection &);;
    int  addConnectionInfo(connection& );
    int  addConnectionInfo(Packet& );
    int  deleteConnectionInfo(connection& );
    void printAllAddedCons();
    void addPacketQuer(PacketQuer *qr);
    Packet *getNextPacket();

    Connections();
    ~Connections();

    private:
    void *informations;    
    PacketQuer *_quer;
};

#endif
